import request from 'umi-request';

export async function queryAwardList(params,tabIndex) {
  return request('/hr-ssc/api/api-admin/salary/getAwardApplicantPage', {
    method: 'get',
    params: {
      pageNum: params.current,
      pageSize: params.pageSize,
      applicantName:params.applicantName,
      usercode:params.usercode,
      startTime:params.startTime,
      endTime:params.endTime,
      awardName:params.awardName,
      approvalStatus:tabIndex === '1' ? null : tabIndex
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function saveAwardInfo(params) {
  return request('/hr-ssc/api/api-admin/salary/saveAwardInfo', {
    method: 'POST',
    data: {
      ...params,
      orgId:params.awardOrgId
    },
  }).then(( res) => {
    return res;
  });
}

export async function getIdAwardInfo(id) {
  return request(`/hr-ssc/api/api-admin/salary/getAwardInfoById/${id}`, {
    method: 'get',
  }).then((res) =>{
    return res.data;
  });
}

export async function awardBpm(id) {
  return request(`/hr-ssc/api/api-admin/bpm/awardBpm`, {
    method: 'get',
    params: {
      id:id
    }
  }).then((res) =>{
    return res;
  });
}

export async function getReAndPu() {
  return request(`/hr-ssc/api/api-admin/job/findReAndPu`, {
    method: 'get',
  }).then((res) =>{
    return res.data;
  });
}

export async function getEmpByUnitId(ids) {
  return request(`/hr-ssc/api/api-admin/job/getEmpByUnitId`, {
    data:{
      ids:ids
    },
    method: 'post',
    requestType: 'form'
  }).then((res) => {
    return res.data;
  });
}

export async function getAwardInfo(serialNum) {
  return request(`/hr-ssc/api/api-admin/salary/getAwardInfo`, {
    method: 'get',
    params:{
      serialNum:serialNum
    }
  }).then((res) =>{
    return res.data;
  });
}


